package com.zxl.yjb.adapter;

import android.text.TextUtils;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.zxl.yjb.R;
import com.zxl.yjb.bean.NearbyHelpBean;
import com.zxl.yjb.http.HostUrl;
import com.zxl.yjb.utils.GenerateMapBitmapUtil;
import com.zxl.yjb.utils.GlideUtil;

public class NearbyHelpListAdapter extends BaseQuickAdapter<NearbyHelpBean, BaseViewHolder> {

    public NearbyHelpListAdapter(int layoutResId) {
        super(layoutResId, null);
    }

    @Override
    protected void convert(BaseViewHolder helper, NearbyHelpBean item) {
        helper.setText(R.id.tv_my_name, TextUtils.isEmpty(item.getNickname())?item.getUid()+"":item.getNickname());
        helper.setText(R.id.tv_time, item.getAddtime());
        helper.setText(R.id.tv_my_id, "uid:"+item.getUid()+"");

        if (item.getOrign_remark()!=null) {
            helper.setText(R.id.tv_content, item.getOrign_remark().toString());
        }else {
            helper.setText(R.id.tv_content, "");
        }
//        Glide.with(mContext).load(mapUrl).into(ivMap);
        ImageView iv = helper.getView(R.id.iv_my_header);
        Glide.with(mContext).load(HostUrl.HOSTPIC +item.getFace_img()).into(iv);

        String mapUrl="";
        ImageView ivMap = helper.getView(R.id.iv_map);
        //获取静态地图图片
        String latitude = item.getLatitude();
        String longitude = item.getLongitude();
        if (!TextUtils.isEmpty(latitude)&&!TextUtils.isEmpty(longitude)){
            try {
                mapUrl = GenerateMapBitmapUtil.getMapUrl(Double.parseDouble(latitude),Double.parseDouble(longitude));
            }catch (Exception e){
                e.printStackTrace();
            }
        }
        GlideUtil.load(mContext,mapUrl,ivMap,R.mipmap.help_map,R.mipmap.help_map);
    }
}
